﻿// <!CDATA[


var bMaintainSelection = 0
function body_onload()
{
//    //debugger;
//    var Viewer1 =  document.getElementById("Viewer1").object; 
//    var hdnShapeID = window.parent.document.getElementById("tabsHIPO$tabVisio$hdnShapeID");
//    
//    if (hdnShapeID.value.length) 
//    { 
//      bMaintainSelection = 1;
//      Viewer1.SelectShape(hdnShapeID.value);
//      bMaintainSelection = 0
//    }
//    
}

function Viewer1_OnViewChanged() {
    var ViewerControl = document.getElementById("Viewer1");
    var Viewer1 =  document.getElementById("Viewer1").object; 
    var PageXAtViewCenter=0.0, PageYAtViewCenter=0.0, ZoomFactor=1
    Viewer1.GetPageView(PageXAtViewCenter, PageYAtViewCenter, ZoomFactor);
    
    
    
    //Can use ViewerControl to get the param settings for cx, cy and zoom.
    //Save them to a hidden control (on the Default page?) every view change
    //so that they can be restored when the drawing is re-drawn on the server
    //How do you plug them in? 
    //Gotta be server functions to Zoom to a point!
    //Can you macro it and capture the code?

    //debugger;
}


function Viewer1_OnSelectionChanged() {
//    if (bMaintainSelection == 0)
//    {
        var Viewer1 =  document.getElementById("Viewer1").object; 
        var hdnShapeID = window.parent.document.getElementById("tabsHIPO$tabVisio$hdnShapeID");
        var i = Viewer1.SelectedShapeIndex;
        var j = Viewer1.ShapeIndexToID(i);
        var theform = window.parent.document.forms[0];
        theform.__EVENTTARGET.value = "Viewer1";
        theform.__EVENTARGUMENT.value = j;
        hdnShapeID.value = i;
        
        var btnRefresh = window.parent.document.getElementById("tabsHIPO$tabVisio$btnRefresh");
        btnRefresh.click();
//    }   
    
    //alert("ID:" + Viewer1.ShapeIndexToID(Viewer1.SelectedShapeIndex) + "\tIndex:" + Viewer1.SelectedShapeIndex);
    //var x;
    //x = New ActiveXObject("Visio.Application");
    //__doPostBack('Viewer1', Viewer1.ShapeIndexToID(Viewer1.SelectedShapeIndex));
}

<!--
  function __doPostBack(eventTarget, eventArgument) {
        var theform = window.document.ctrl2;
        theform.__EVENTTARGET.value = eventTarget;
        theform.__EVENTARGUMENT.value = eventArgument;
        theform.submit();
  }
  
  
function Viewer1_DocumentOpened() {

    debugger;
}
  
function Viewer1_OnDocumentLoaded()
{
    debugger;
} 
// -->

// ]]>

